<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>class类对象继承</title>
  </head>
  <body>
    <div></div>
    <script>
      function Phone(name, price) {
        this.name = name
        this.price = price
      }

      Phone.prototype.call = function () {
        console.log("打电话")
      }
      //智能手机
      function smartPhone(name, price, color, size) {
        Phone.call(this, name, price) //执行一遍父类的属性
        this.color = color
        this.size = size
      }

      //设置子级构造函数的原型
      smartPhone.prototype = new Phone() //继承父类原型的一些方法
      smartPhone.prototype.constructor = smartPhone

      //声明子类原型连的方法
      smartPhone.prototype.plauGame = function () {
        console.log("打游戏")
      }
      //创建一个实例
      let apple = new smartPhone("苹果", 6999, "白色", "5.5")
      //console.log(apple.__proto__.constructor)
    </script>
  </body>
</html>
